<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		6.从键盘分别输入年、月、日，判断这一天是当年的第几天
		 
		   注：判断一年是否是闰年的标准：
		       1）可以被4整除，但不可被100整除
		       2）可以被400整除
			   
			<br>
			年<input type="text" id="input_year" value="2020"/><br>
			月<input type="text" id="input_month" value="7"/><br>
			日<input type="text" id="input_day" value="1"/><br>
			<button type="button" onclick="cal()">计算</button><br>
			<span>
				结果为：
			</span>
			
			<script type="text/javascript">
				function cal(){
					let input_year = document.getElementById("input_year");
					let input_month = document.getElementById("input_month");
					let input_day = document.getElementById("input_day");
					let year = parseInt(input_year.value);
					let month = parseInt( input_month.value);
					let day = parseInt(input_day.value);
					switch (month){
						case 12:
							day += 31;
						case 11:
							day += 30;
						case 10:
							day += 31;
						case 9:
							day += 30;
						case 8:
							day += 31;
						case 7:
							day += 31;
						case 6:
							day += 30;
						case 5:
							day += 31;
						case 4:
							day += 30;
						case 3:
							if(isRun(year)){
								day += 29;
							}else{
								day += 28;
							}
						case 2:
							day += 31;
						case 1:
					}
					let span = document.getElementsByTagName("span")[0];
					span.innerText = "是第" + day + "天";
				}
					
				function isRun(year){
					if((year % 4 === 0) || (year % 400 === 0)){
						return true;
					}
				}
			</script>
	</body>
</html>
